package tookit;

public class Debug
{
	private static boolean enabled = true;
	
	public static void setEnabled(boolean enabled)
	{
		Debug.enabled = enabled;
		
		if (!enabled)
		{
			System.err.close();
		}
	}
	
	public static boolean isEnabled()
	{
		return enabled;
	}

	public static void log(Object o)
	{
		log(o, null);
	}
	
	public static void log(Object o, String label)
	{
		if (enabled)
		{
			if (o instanceof Exception)
			{
				Exception e = (Exception) o;
				
				e.printStackTrace();
			}
			else
			{
				System.out.println(label != null ? label + ": " + o : o);
			}
		}
	}
	
	public static void printLine()
	{
		if (enabled)
		{
			System.out.println();
		}
	}
	
	public static void printSolidLine()
	{
		if (enabled)
		{
			System.out.println("\n===============\n");
		}
	}
}
